<?php
/**
 * Created by PhpStorm.
 * User: jwb
 * Date: 2021/3/29
 * Time: 16:22
 */

namespace App\Services;


use App\Expert;
use Encore\Admin\Grid;
use Encore\Admin\Grid\Tools\BatchActions;
use Encore\Admin\Show;
use Encore\Admin\Widgets\Tab;
use Encore\Admin\Facades\Admin;

class ExpertService
{
    public function gridColumn(Grid $grid)
    {
        $that = $this;
        $grid->column('name', __('姓名'))->modal('详情', function ($model) use ($that) {
            return $that->detail($model);
        });
        $grid->column('major', __('专业'));
        $grid->column('education', __('学历'));
        $grid->column('graduation_school', __('毕业学校'));
        $grid->column('title', __('职称'))->hide();
        $grid->batchActions(function (BatchActions $actions) {
            $actions->disableDeleteAndHodeSelectAll();
        });
        $grid->disableFilter();
        $grid->quickSearch('name')->placeholder('请输入姓名');
        $grid->disableExport();
        return $grid;
    }

    public function detail(Expert $model)
    {
        $tab = new Tab();
        $tab->add('基本信息', Admin::show($model, function (Show $show) {
            $show->panel()->view('show.tab-panel');
            $show->field('name', __('姓名'));
            $show->field('major', __('专业'));
            $show->field('education', __('学历'));
            $show->field('graduation_school', __('毕业学校'));
            $show->field('graduation_date', __('毕业时间'));
            $show->field('title', __('职称'));
            $show->field('title_date', __('职称获取时间'));
        }));
        $tab->add('个人简介', '<div style="padding: 20px">' . $model->desc . '</div>');
        $tab->add('研究方向', '<div style="padding: 20px">' . $model->research . '</div>');
        $tab->add('主要成就', '<div style="padding: 20px">' . $model->achievement . '</div>');

        $style = <<<STYLE
.nav-tabs-custom>.nav-tabs {
        border-bottom-color: #3c8dbc;
    }
    .nav-tabs-custom>.nav-tabs>li.active>a {
        border-left-color: #3d6e8a;
        border-right-color: #3d6e8a;
    }
STYLE;
        Admin::style($style);
        return $tab;
    }
}
